let mongoose = require('mongoose')
let dbUrl = 'mongodb://baby:baby@localhost:27017/baby'

const ops = {
  init: function () {
    mongoose.connection.openUri(dbUrl)
    // mongoose.connect(dbUrl, {auth: {authdb: 'baby', username: 'baby', password: 'baby'}, useMongoClient: true})

    mongoose.connection.on('connected', function () {
      console.log('mongodb ready')
    })

    mongoose.connection.on('error', function (err) {
      console.log('mongodb connection error: ' + err)
    })

    mongoose.connection.on('disconnected', function () {
      console.log('mongodb connection disconnected')
    })
  }
}

module.exports = ops
